package com.example.demo.permission.menurole.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.demo.permission.menurole.dao.MenuRoleMapper;

@Service
@Transactional
public class MenuRoleService {
	@Autowired
	MenuRoleMapper menuRoleMapper;

	/**
	 * 
	 * 方法描述: 先根据角色id删除菜单， 然后在添加角色所要的菜单
	 * 
	 * @param rid
	 * @param mids
	 * @return
	 * @author lixh
	 */

	public int updateMenuRole(Long rid, Long[] mids) {
		menuRoleMapper.deleteMenuByRid(rid);
		if (mids.length == 0) {
			return 0;
		}
		return menuRoleMapper.addMenu(rid, mids);
	}

}
